# coding=utf-8
# 全世界最帅的帅哥
from flask import Flask
from ysgg1_club_auth.comment.utils.jwt_manager import jwt_manager
from ysgg1_club_auth.config.app_config import AuthConfig
from flask_migrate import Migrate
from ysgg1_club_auth.comment.utils.auth_logging import create_logger
from ysgg1_club_comment.nacos_client import client


def create_app():
    app = Flask(__name__)
    app.config.from_object(AuthConfig)

    app.logger = create_logger(app)

    from ysgg1_club_comment.modules import db
    db.init_app(app)

    Migrate(app, db)

    jwt_manager.init_app(app)

    from ysgg1_club_auth.auth_domain import user_bp
    app.register_blueprint(user_bp)

    client.add_naming_instance(
        "ysgg1_club_auth", "localhost", "6000", heartbeat_interval=5
    )

    return app
